<!--
  * 首页
  *
  * @Author:    1024创新实验室-主任：卓大
  * @Date:      2022-09-12 22:34:00
  * @Wechat:    zhuda1024
  * @Email:     lab1024@163.com
  * @Copyright  1024创新实验室 （ https://1024lab.net ），Since 2012
  *
-->
<template>
  <div class="mainbody">
    <!-- 头部的盒子 -->
    <header>
      <h1>数据可视化-ECharts</h1>
      <div class="showTime"></div>
    </header>
    <!-- 页面主体部分 -->
    <section class="mainbox">
      <!-- 左边的图形展示 -->
      <div class="column">
        <!--  第一列柱形图   -->
        <div class="panel bar">
          <h2>柱形图</h2>
          <div class="chart">图表</div>
          <div class="panel-footer"></div>
        </div>
        <!--  第一列折线图   -->
        <div class="panel bar">
          <h2>柱形图</h2>
          <div class="chart">图表</div>
          <div class="panel-footer"></div>
        </div>
        <!--  第一列饼图   -->
        <div class="panel bar">
          <h2>柱形图</h2>
          <div class="chart">
            <Pie></Pie>
          </div>
          <div class="panel-footer"></div>
        </div>
      </div>
      <!-- 中间的图形展示 -->
      <div class="column">
        <div class="no">
          <div class="no-hd">
            <ul>
              <li>287122</li>
              <li>123231</li>
            </ul>
          </div>
          <div class="no-bd">
            <ul>
              <li>前端需求人数</li>
              <li>市场供应人数</li>
            </ul>
          </div>
        </div>
        <div class="map">
          <div class="map1"></div>
          <div class="map2"></div>
        </div>
      </div>
      <!-- 右边的图形展示 -->
      <div class="column">
        <!--  第三列柱形图   -->
        <div class="panel bar">
          <h2>柱形图</h2>
          <div class="chart">图表</div>
          <div class="panel-footer"></div>
        </div>
        <!--  第三列折线图   -->
        <div class="panel bar">
          <h2>柱形图</h2>
          <div class="chart">图表</div>
          <div class="panel-footer"></div>
        </div>
        <!--  第三列饼图   -->
        <div class="panel bar">
          <h2>柱形图</h2>
          <div class="chart">图表</div>
          <div class="panel-footer"></div>
        </div>
      </div>
    </section>
  </div>
</template>
<script>
// 1. 引入 Pie 组件（路径确保和实际文件位置一致）
import Pie from './components/echarts/pie.vue';

// 2. 关键：用 Options API 注册组件（必须写 export default + components 选项）
export default {
  components: { Pie }, // 注册 Pie 组件，模板中才能用 <Pie>
  mounted() {
    // 3. 定时器逻辑移到 mounted 生命周期（确保 DOM 渲染后执行）
    let t = null;
    t = setTimeout(this.time, 1000);
  },
  methods: {
    time() {
      clearTimeout(this.t);
      const dt = new Date();
      const y = dt.getFullYear();
      const mt = dt.getMonth() + 1;
      const day = dt.getDate();
      const h = dt.getHours().toString().padStart(2, '0'); // 补零优化
      const m = dt.getMinutes().toString().padStart(2, '0');
      const s = dt.getSeconds().toString().padStart(2, '0');
      // 避免 DOM 未找到的报错
      const showTimeEl = document.querySelector('.showTime');
      if (showTimeEl) {
        showTimeEl.innerHTML = `当前时间：${y}年${mt}月${day}日 ${h}:${m}:${s}`;
      }
      this.t = setTimeout(this.time, 1000);
    }
  }
};
</script>
<style>
  .mainbody {
    background: url('/@/assets/images/kanban/bg.jpg') no-repeat top center;
    height: 100%;
    width: 100%;
    overflow: hidden;
  }

  li {
    list-style: none;
  }

  header {
    position: relative;
    height: 4rem;
    background: url('/@/assets/images/kanban/head_bg.png') no-repeat;
    background-size: 100% 100%;
    width: 100%;

    h1 {
      font-size: 38px;
      color: white;
      text-align: center;
      line-height: 4rem;
    }

    .showTime {
      top: 0;
      position: absolute;
      right: 0.375rem;
      line-height: 75px;
      color: rgba(255, 255, 255, 0.7);
      font-size: 20px;
    }
  }

  .mainbox {
    display: flex;
    width: 100%;
    height: 100%; /* 相对于父元素的高度 */
    margin: 0 auto;
    padding: 10px 0 10px 0;

    .column {
      flex: 3;
      margin: 10px 15px 0;
    }

    .column:nth-child(2) {
      flex: 5;
    }

    .panel {
      position: relative;
      height: 250px;
      border: 1px solid rgba(25, 186, 139, 0.17);
      background: url('/@/assets/images/kanban/line1.png') rgba(255, 255, 255, 0.04);
      padding: 0 0.1875rem 0.5rem;
      margin-bottom: 0.1875rem;

      &::before {
        position: absolute;
        top: 0;
        left: 0;
        content: '';
        width: 10px;
        height: 10px;
        border-top: 2px solid #02a6b5;
        border-left: 2px solid #02a6b5;
      }

      &::after {
        position: absolute;
        top: 0;
        right: 0;
        content: '';
        width: 10px;
        height: 10px;
        border-top: 2px solid #02a6b5;
        border-right: 2px solid #02a6b5;
      }

      .panel-footer {
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;

        &::before {
          position: absolute;
          bottom: 0;
          left: 0;
          content: '';
          width: 10px;
          height: 10px;
          border-bottom: 2px solid #02a6b5;
          border-left: 2px solid #02a6b5;
        }

        &::after {
          position: absolute;
          bottom: 0;
          right: 0;
          content: '';
          width: 10px;
          height: 10px;
          border-bottom: 2px solid #02a6b5;
          border-right: 2px solid #02a6b5;
        }
      }

      h2 {
        height: 0.6rem;
        line-height: 0.6rem;
        text-align: center;
        color: #fff;
        font-size: 20px;
        font-weight: 400;
      }

      .chart {
        height: 240px;
      }
    }
  }

  /* 声明字体*/
  @font-face {
    font-family: electronicFont;
    src: url('/@/assets/images/kanban/font/DS-DIGIT.TTF');
  }

  .no {
    background: rgba(101, 132, 226, 0.1);
    padding: 0.1875rem;

    .no-hd {
      position: relative;
      border: 1px solid rgba(25, 186, 139, 0.17);

      &::before {
        content: '';
        position: absolute;
        width: 30px;
        height: 10px;
        border-top: 2px solid #02a6b5;
        border-left: 2px solid #02a6b5;
        top: 0;
        left: 0;
      }

      &::after {
        content: '';
        position: absolute;
        width: 30px;
        height: 10px;
        border-bottom: 2px solid #02a6b5;
        border-right: 2px solid #02a6b5;
        right: 0;
        bottom: 0;
      }

      ul {
        display: flex;

        li {
          position: relative;
          flex: 1;
          text-align: center;
          height: 30px;
          line-height: 40px;
          font-size: 30px;
          color: #ffeb7b;
          padding: 0.05rem 0;
          font-family: electronicFont;
          font-weight: bold;

          &:first-child::after {
            content: '';
            position: absolute;
            height: 50%;
            width: 1px;
            background: rgba(255, 255, 255, 0.2);
            right: 0;
            top: 25%;
          }
        }
      }
    }

    .no-bd ul {
      display: flex;

      li {
        flex: 1;
        height: 20px;
        line-height: 20px;
        text-align: center;
        font-size: 20px;
        color: rgba(255, 255, 255, 0.7);
        padding-top: 10px;
      }
    }
  }

  .map {
    position: relative;
    height: 670px;

    .chart {
      position: absolute;
      top: 0;
      left: 0;
      z-index: 5;
      height: 10.125rem;
      width: 100%;
    }

    .map1,
    .map3 {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 518px;
      height: 518px;
      background: url('/@/assets/images/kanban/map.png') no-repeat;
      background-size: 100% 100%;
      opacity: 0.3;
    }

    .map2 {
      position: absolute;
      top: 50%;
      left: 50%;
      width: 643px;
      height: 643px;
      background-image: url('/@/assets/images/kanban/lbx.png');
      opacity: 0.6;
      animation: rotate 15s linear infinite;
      z-index: 2;
    }

    .map3 {
      width: 7.075rem;
      height: 7.075rem;
      background-image: url('/@/assets/images/kanban/jt.png');
      animation: rotate1 10s linear infinite;
    }

    @keyframes rotate {
      from {
        transform: translate(-50%, -50%) rotate(0deg);
      }
      to {
        transform: translate(-50%, -50%) rotate(360deg);
      }
    }
    @keyframes rotate1 {
      from {
        transform: translate(-50%, -50%) rotate(0deg);
      }
      to {
        transform: translate(-50%, -50%) rotate(-360deg);
      }
    }
  }
</style>
